﻿using AppService.IService.System_Carrier_ment;
using Domain.Entity.Basic_information;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace WebAPI.Controllers.System_Carrier_ment
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Carrier_mentController : ControllerBase
    {
        private readonly ICarrier_mentService carrier_MentService;

        public Carrier_mentController(ICarrier_mentService carrier_MentService)
        {
            this.carrier_MentService = carrier_MentService;
        }

        /// <summary>
        /// 查询承运商,司机,车辆的相关数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<Carrier_ment> Get_Ments(int currentPage, int PageSize) 
        { 
            return carrier_MentService.GetCarrier_Ments(currentPage,PageSize);
        }

        /// <summary>
        /// 查询数据总数
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public int Count(string? time, string? Cr_cp_name)
        {
            return carrier_MentService.Count(time, Cr_cp_name);
        }

        /// <summary>
        /// 查询全部承运商数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<Carrier_ment> Carrier_Ments()
        {
            return carrier_MentService.Carrier_Ments_();
        }

        /// <summary>
        /// 根据id删除
        /// </summary>
        /// <param name="Cr_id"></param>
        /// <returns></returns>
        [HttpDelete]
        public bool Delete(int Cr_id)
        {
            return carrier_MentService.Delete(Cr_id);
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="carrier_Ment"></param>
        /// <returns></returns>
        [HttpPost]
        public bool Add(Carrier_ment carrier_Ment)
        {
            return carrier_MentService.Add(carrier_Ment);
        }

        /// <summary>
        /// 根据创建时间和公司名称查询
        /// </summary>
        /// <param name="time"></param>
        /// <param name="Cr_cp_name"></param>
        /// <param name="currentPage"></param>
        /// <param name="PageSize"></param>
        /// <returns></returns>
        [HttpGet]
        public List<Carrier_ment> Carrier_Ments_time(string? time, string? Cr_cp_name, int currentPage, int PageSize)
        {
            return carrier_MentService.GetCarrier_Ments_time(time, Cr_cp_name, currentPage, PageSize);
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="carrier_Ment"></param>
        /// <returns></returns>
        [HttpPost]
        public bool Update(Carrier_ment carrier_Ment)
        {
            return carrier_MentService.Update(carrier_Ment);
        }

        /// <summary>
        /// 根据id查询
        /// </summary>
        /// <param name="Cr_id"></param>
        /// <returns></returns>
        [HttpGet]
        public List<Carrier_ment> GetCarrier_Ments_Update(int Cr_id)
        {
            return carrier_MentService.GetCarrier_Ments_Update(Cr_id);
        }
    }
}
